const express = require("express")
const bodyParser = require('body-parser')
let usersRoute = require("./route/usersRoute")
let loginRouter = require("./route/loginRoute")
let adminRoute = require("./route/adminRoute")
const { expressjwt } = require("express-jwt");
const { application } = require("express")
const advRoute = require("./route/advRoute")
let app = express()
app.use(expressjwt({ secret: "mytoken", algorithms: ['HS256'] }).unless({ path: [/\.png$/, /\.webp$/, "/login/loginUser"] }))
app.use(express.static("./static"))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use("/users", usersRoute)// 检测到users会访问新路由,形成二级路由
app.use("/login", loginRouter)// 检测到users会访问新路由,形成二级路由
app.use("/admin", adminRoute)// 检测到users会访问新路由,形成二级路由
app.use("/adv", advRoute)// 检测到users会访问新路由,形成二级路由
app.listen(8787)